// Achievement by G3X / GeXeH - Enjoy
// Version 1.0

// Achievement: Kill 100 Zombie NPCs.

local killed = achievements.GetValue( "Hoard Control", "total", 0 )

local zombie = { "npc_zombie", "npc_zombie_torso", "npc_fastzombie", "npc_fastzombie_torso", "npc_poisonzombie", "npc_zombine" }
local function PlayerKilledNPC( msg )
	local victim, inflictor, attacker = msg:ReadString(), msg:ReadString(), msg:ReadEntity()
	
	if ( killed != 100 && attacker == LocalPlayer() ) then
		if ( table.HasValue( zombie, victim ) ) then
			killed = math.Clamp( killed + 1, 0, 100 )
			achievements.SetValue( "Hoard Control", "total", killed )
			achievements.Update( "Hoard Control", killed / 100, killed .. "/100" )
		end
	end		
	
	return victim, inflictor, attacker
end
usermessage.AddHook( "PlayerKilledNPC", "Achievements.HoardControl", PlayerKilledNPC )

achievements.Register( "Hoard Control", "Kill 100 Zombie NPCs.", "achievements/hoardcontrol", killed / 100, killed .. "/100" )